import org.jsoar.kernel.Agent;
import org.jsoar.kernel.SoarException;
import org.jsoar.runtime.ThreadedAgent;
import org.jsoar.util.commands.DefaultInterpreter;
import org.jsoar.util.commands.SoarCommandInterpreter;
import org.jsoar.util.commands.SoarCommands;

import java.io.File;
import java.io.OutputStreamWriter;

public class UserGuideMain {
    public static void main(String[] args) throws SoarException {
        // 创建 JSoar 智能体
        Agent agent = new Agent();

        try {
            // 获取智能体的解释器
            SoarCommandInterpreter interpreter = agent.getInterpreter();

            // 加载 Soar 文件
            SoarCommands.source(interpreter, "Z:\\SOAR\\SoarTutorial_9.6.0-Multiplatform_64bit\\agents\\water-jug-simple\\water-jug.soar");
            System.out.println("Soar file loaded successfully.");

            // 将运行结果输出到控制台
            agent.getPrinter().pushWriter(new OutputStreamWriter(System.out));

            // 运行智能体一段时间
            agent.runForever();
        } catch (SoarException e) {
            e.printStackTrace();
            System.err.println("Failed to load Soar file: " + e.getMessage());
        } finally {
            // 清理并关闭智能体
            agent.dispose();
        }
    }
}
